<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" type="text/css" href="/static/lib/datatables/1.10.15/jquery.dataTables.css">
    <div th:include="admin/common :: head"></div>

    <style type="text/css">
        th {
            text-align: center;
        }
        .table td {
            text-align: center;
        }
    </style>
    <title>教师列表</title>
</head>

<body>

<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>用户管理
    <span class="c-gray en">&gt;</span>用户列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>

<div class="cl pd-5 bg-1 bk-gray mt-20">

    <span class="l">

        <a class="btn btn-success-outline radius"onclick="product_add()" href="javascript:;">
        <i class="Hui-iconfont">&#xe644;</i>导出数据</a></span>

    </span>
    <span class="r" >共有数据：<div style="display:inline;line-height:31px" th:text="${userList.size()} ">条</div></span>
</div>

<div class="page-container">
    <div class="mt-20">
        <table id="sheetList" class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr class="text-c">
                <th width="25">
                    <input type="checkbox" name="" value="">
                </th>
                <th width="100">账号</th>
                <th width="100">姓名</th>
                <th width="40">性别</th>
                <th width="90">手机</th>
                <th width="80">学历</th>
                <th width="80">简介</th>
                <th width="70">注册时间</th>
                <th width="100">创建的课程</th>
                <th width="100">记录</th>
                <th width="100">操作</th>
            </tr>
            </thead>

            <tbody>
            <tr  th:each="user,userList : ${userList}" >
                <td><input type="checkbox" th:value="${user.id}"  name=""></td>

                <td >
                    <u style="cursor:pointer" class="text-primary" th:text="${user.username}"
                       th:onclick="|user_show('用户详情','/admin/user/userDetail/${user.id }','${user.id}','450','450')|">
                    </u>
                </td>

                <td th:text="${user.realname}"></td>

                <td th:if="${user.gender}==0" >未知</td>
                <td th:if="${user.gender}==1" >男</td>
                <td th:if="${user.gender}==2" >女</td>

                <td th:if="${user.mobile==null}">无</td>
                <td th:if="${user.mobile!=null}"th:text="${user.mobile}"></td>

                <td th:text="${user.education}" ></td>

                <td th:text="${user.title}"></td>

                <th th:text="${#dates.format(user.createTime, 'yyyy-MM-dd')}"></th>



                <td >
                    <span class="label label-success radius">
					<a style="text-decoration:none" class="ml-5"
                       th:onclick="|user_show('创建的课程','/admin/user/createCourse/${user.id }','${user.id }')|"
                       href="javascript:;" title="创建的课程">创建的课程</a></span>
                </td>

                <td >
                    <span class="label label-success radius">
					<a style="text-decoration:none" class="ml-5"
                       th:onclick="|user_show('创建的课程','/admin/user/createCourse/${user.id }','${user.id }')|"
                       href="javascript:;" title="创建的课程">记录</a></span>
                </td>



                <td class="td-manage">
                    <a title="停用" style="text-decoration:none" onClick="member_stop(this,'10001')" href="javascript:;" >
                        <i class="Hui-iconfont">&#xe631;</i></a>
                    <a title="编辑"  th:onclick="|javascript:user_show('编辑','/admin/user/courseEditPage/${user.id }','4','','510')|"
                       class="ml-5" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6df;</i></a>
                    <!--<a title="删除" href="javascript:;" th:onclick="|javascript:question_del(this,'${user.userId }')|"
                       class="ml-5" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6e2;</i></a>-->
                </td>

            </tr>
            </tbody>
        </table>
    </div>

</div>




<footer th:include="admin/common :: footer"></footer>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/datatables/1.10.15/jquery.dataTables.js"></script>
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript">
    $(function(){
        $('.table-sort').dataTable({
            "aaSorting": [
                [
                    1,"desc"
                ]
            ],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,2,3,7,8,]}// 制定列不参与排序
            ]
        });

    });
    /*用户-添加*/
    function member_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*用户-查看*/
    function user_show(title,url,id,w,h){
        layer_show(title,url,w,h);
    }




    /*用户-停用*/
    function userHr_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){
            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath}/userHr/userHrStop",
                data: {
                    userHrId:id,
                },
                success: function(data){
                    var data = eval('(' + data + ')');
                    if (data.status==1){
                        /* $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="interviewer_start(this,'+id+')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>'); */
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
                        $(obj).remove();
                        layer.msg('已停用!',{icon: 5,time:1000});
                    }else{
                        alert("发生错误!请重新操作");
                    }
                }
            });
        });

    }

    /*用户-启用*/
    function interviewer_start(obj,id){

        layer.confirm('确认要启用吗？',function(index){
            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath}/interviewer/interviewerStart",
                data: {
                    interviewerId:id,
                },
                success: function(data){
                    var data = eval('(' + data + ')');
                    if (data.status==1){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="interviewer_stop(this,'+id+')" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">正常</span>');
                        $(obj).remove();
                        layer.msg('已启用!',{icon: 6,time:1000});
                    }else{
                        alert("发生错误!请重新操作");
                    }
                }
            });
        });
    }





    /*用户-编辑*/
    function userHr_edit(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*密码-修改*/
    function change_password(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*用户-删除*/
    function userHr_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath}/userHr/userHrDelete",
                data: {
                    userHrId:id,
                },
                success: function(data){
                    var data = eval('(' + data + ')');
                    if (data.status==1){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                        /* 不需要重新请求链接 */
                        /* location.href="${pageContext.request.contextPath}/teacher/teacherList" */
                    }else{
                        alert("发生错误!请重新操作");
                    }
                }
            });
        });
    }
</script>

</body>
</html>